package com.blb.java11student.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 向前端返回数据的格式
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseResult<T> {

    //响应码
    private Long code;

    //文字信息
    private String message;

    //具体数据
    private T data;

    public static ResponseResult ok(Object data){
        return new ResponseResult(200L,"ok",data);
    }

    public static ResponseResult error(Long code,String message){
        return new ResponseResult(code,message,null);
    }
}
